/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;

/**
 * <p>Project: app2022 - Nio3
 * <p>Powered by webrx On 2022-01-20 11:29:30
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Nio3 {
    public static void main(String[] args) {
        //写入文件 java1.8
        try (var out = Files.newBufferedWriter(Paths.get("m.txt"), StandardCharsets.UTF_8)) {
            out.write("hello 中文234234\n");
            out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }

        //写入文件 java1.8 追加方式
        try (var out = Files.newBufferedWriter(Paths.get("m2.txt"), StandardCharsets.UTF_8, StandardOpenOption.APPEND)) {
            out.write("hello 中文234234\n");
            out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
